Ext.define('KitchenSink.view.examples.tabs.FramedTabs', {
    extend: 'KitchenSink.view.examples.Example',
    requires: [
        'Ext.tab.Panel'
    ],

     defaults: {
         width:800,
         height:500
     },
   
    items: [
        {
            xtype: 'tabpanel',
            frame: true,
            defaults: {
                bodyPadding: 10,
                autoScroll: true,
                styleHtmlContent: true
            },
            margin: '10 0 20 0',
            items: [
					{
						xtype: 'form',
					    title: '基本设置',
					    id:'baseInfoSetting',
					    frame:true,
					    height: null,
					    defaultType: 'textfield',
					    items: [
							{ 
								xtype: 'radiogroup',
							    fieldLabel: '是否自动挂机',
							    columns: 5,
							    vertical: true,
							    items: [
							        { boxLabel: '挂机', name: 'gameParam_openHelper', inputValue: '1' , checked: true},
							        { boxLabel: '不挂机', name: 'gameParam_openHelper', inputValue: '0'},
							    ]
							},
					        { 
					        	xtype: 'radiogroup',
					            fieldLabel: '征收是否开启',
					            columns: 5,
					            vertical: true,
					            items: [
					                { boxLabel: '开启', name: 'gameParam_openImpose', inputValue: '1' , checked: true},
					                { boxLabel: '不开启', name: 'gameParam_openImpose', inputValue: '0'},
					            ]
					        },
					        { allowBlank:false, fieldLabel: '征收次数',maxLength:2, name: 'gameParam_imposeTimes', emptyText: '0', inputType: 'text' ,regex:/^[1-9]\d*$/,regexText:'请输入数字'},
					        { allowBlank:false, fieldLabel: '保留次数', maxLength:2,name: 'gameParam_retainTimes', emptyText: '0', inputType: 'text' ,regex:/^[1-9]\d*$/,regexText:'请输入数字'},
					    ],
					    buttons: [
					        {
					        	text:'保存',
					        	handler:function ()
						        	{
					        			var sForm = Ext.getCmp("baseInfoSetting").getForm(); 
					        			if(!sForm.isValid())
					        			{
					        				Ext.Msg.alert('校验失败','请输入合法的数据');    
					        				return;
					        			}
					        			sForm.doAction('submit',{
					        				clientValidation:false,
							                url:'http://localhost:8080/pages/gameSetting.jsp',
							                method:'post', 
							                params:{gid:astdConstant.gid},
					                        waitTitle:"请稍候",  
					                        waitMsg:"正在提交表单数据，请稍候。。。。。。",  
					                        success:function(form,action)
					                        {  
					                            var isSuccess = action.result.success;   
				                                if(isSuccess)
				                                {  
				                                    Ext.Msg.alert('操作成功','操作成功');                                                          
				                                }else
				                                {
				                                	 Ext.Msg.alert('操作失败',action.result.code);               
				                                }
					                                
					                                  
					                        },  
					                        failure:function(form, action)
					                        {  
					                        	if(action.result.code == 302)
				                        		{
					                        		Ext.Msg.confirm('您尚未登录','请重新登录',function(){self.location='/js/login.html'});  
					                        		
				                        		}else
				                        		{
				                        			Ext.Msg.alert('操作失败',action.result.code);  
				                        		}
					                        }  
					        			});
						        	}
					        }
					    ],
					    listeners: {
					    		beforeactivate:function(){this.ssFun()},
					    	},
				    	ssFun: function(){
				    		var sForm = Ext.getCmp("baseInfoSetting").getForm(); 
				        	sForm.load({
				        		url : "/pages/loadSetting.jsp",     
				        		method : "POST",
				        		params : {
				        			gid:astdConstant.gid
				        		},
				        		reader: new Ext.data.JsonReader({
				                     root: 'data',
				                     successProperty :'success'},
				                     [
				                      	{name:"gameParam_retainTimes ",mapping:"gameParam_retainTimes"},
				                      	{name:"gameParam_openImpose ",mapping:"gameParam_openImpose"},
				                      	{name:"gameParam_openHelper ",mapping:"gameParam_openHelper"},
				            			{name:"gameParam_imposeTimes ",mapping:"gameParam_imposeTimes"}
				                     ]
				        		)
				        	});
				    	}
					},
	                {
							xtype: 'form',
						    title: '征收',
						    frame:true,
						    height: null,
						    defaultType: 'textfield',
						    items: [
						        { allowBlank:false, fieldLabel: '征收时间', name: 'user', emptyText: 'user id' },
						        { allowBlank:false, fieldLabel: '征收次数', name: 'pass', emptyText: 'password', inputType: 'password' },
						        { xtype:'checkbox', fieldLabel: 'Remember me', name: 'remember' }
						    ],
						    
						    buttons: [
						        {text:'Register'},
						        {text:'Login'}
						    ]
	                },
	                {
	                	xtype: 'form',
					    title: '纺织',
					    frame:true,
					    height: null,
					    defaultType: 'textfield',
					    items: [
					        { allowBlank:false, fieldLabel: '纺织次数', name: 'user', emptyText: 'user id' },
					        { allowBlank:false, fieldLabel: 'Password', name: 'pass', emptyText: 'password', inputType: 'password' },
					        { xtype:'checkbox', fieldLabel: 'Remember me', name: 'remember' }
					    ],
					    
					    buttons: [
					        {text:'Login'}
					    ]
	                }
            ]
            ,
            listeners: {
                'tabchange': function(tabPanel, tab){
                    alert(tab.getName());
                }
            }
        }
    ],
    
    
});